package tx.oopa.circuit.port.impl;

import tx.oopa.circuit.port.AbstractComponent;
import tx.oopa.circuit.port.AbstractDoublePort;

/**
 * Implementation of the logical NAND function:
 * 
 * True False => True
 * False True => True
 * False False => True
 * True True => False
 * 
 * @author Xander van Rijn
 *
 */
public class NANDPort extends AbstractDoublePort {

    private static final String ID = "NAND";
    @SuppressWarnings("unused")
    private static NANDPort instance = new NANDPort(ID);
    
    protected NANDPort() {}
    
    protected NANDPort(String ID) {
        super(ID);
    }
    
    @Override
    public Boolean performLogicalFunction() {
        return !(this.firstInput && this.secondInput);
    }

    @Override
    public AbstractComponent clone() {
        return new NANDPort();
    }
    
    public String getID() {
        return ID;
    }
}

